package com.niit.servlet;

import com.niit.pojo.StudentTable;
import com.niit.service.HbaseService;
import com.niit.service.impl.HbaseServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @author Keven-赵仕星
 * @date 2022/2/11 9:44
 */
@WebServlet("/display_individual")
public class display_indivServlet extends HttpServlet {

    public void init(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        StudentTable studentTable = new StudentTable(req.getParameter("studentId"), req.getParameter("studentName"),
                req.getParameter("enrollment"), req.getParameter("phone"), req.getParameter("semester"),
                req.getParameter("status")
        );

        HbaseService hbaseService = new HbaseServiceImpl();
        List<StudentTable> studentTables = hbaseService.displayByindividual(studentTable);
        init(req, resp);
        req.setAttribute("StudentList", studentTables);
        req.getRequestDispatcher("/pages/queryDisplayPage.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }


}
